package com.zoiz.base.controller;

import com.zoiz.base.model.Admin_menu;
import com.zoiz.plus.Path;
import com.zoiz.plus.extend.Controller;
import com.zoiz.plus.renderer.Renderer;
@Path("/admin")
public class AdminController extends Controller {
	@Path("/index")
	public Renderer index(){
		push("menus", Admin_menu.findAllBy("parentid=1 order by showorder"));
		return render("admin/index_menu.html");
	}
	@Path("/leftMenu/$1")
	public Renderer getLeftMenu(Long id){
		StringBuilder sql = new StringBuilder();
		sql.append("SELECT node.*");
		sql.append("  FROM admin_menu node, admin_menu parent");
		sql.append(" WHERE node.lft BETWEEN parent.lft+1 AND parent.rgt");
		sql.append("   AND parent.id = ? ORDER BY node.lft");
		return renderJson(Admin_menu.findAllBy(sql.toString(), id));
	}
}
